package com.flyoil.petromp.apiservice;


import java.util.HashMap;
import java.util.Map;

import okhttp3.RequestBody;
import rx.Subscriber;

/**
 * Created by bingju on 2017/2/15.
 */

public class HttpModel extends HttpModelBase {
    private int id = 0;

    /**
     * 用户登录
     */
    public void login_server(Map<String, Object> map, Subscriber subscriber) {
        Map<String, Object> maps = getMap(map);
        setModel(retrofitApiSerivce.login(maps), subscriber);
    }

    /**
     * 退出登录
     */
    public void logout_server(Map<String, Object> map, Subscriber subscriber) {
        Map<String, Object> maps = getMap(map);
        setModel(retrofitApiSerivce.logout(maps), subscriber);
    }

    /**
     * 获取用户信息
     */
    public void getUserMessage(Map<String, Object> map, Subscriber subscriber) {
        Map<String, Object> maps = getMap(map);
        setModel(retrofitApiSerivce.getUserMessage(maps), subscriber);
    }

    /**
     * 修改用户密码
     */
    public void setPassword(Map<String, Object> map, Subscriber subscriber) {
        Map<String, Object> maps = getMap(map);
        setModel(retrofitApiSerivce.resetPassword(maps), subscriber);
    }

    /**
     * 上传用户头像
     */
    public void uploadAvatar(Map<String, RequestBody> map, Subscriber subscriber) {
        Map<String, RequestBody> maps = getMapRequestBody(map);
        setModel(retrofitApiSerivce.uploadAvatar(maps), subscriber);
    }

    /**
     * 上传用户签名文件
     */
    public void uploadSignature(Map<String, RequestBody> map, Subscriber subscriber) {
        Map<String, RequestBody> maps = getMapRequestBody(map);
        setModel(retrofitApiSerivce.uploadSignature(maps), subscriber);
    }

    /**
     * 获取我的消息列表
     */
    public void getMessageList(Map<String, Object> map, Subscriber subscriber) {
        Map<String, Object> maps = getMap(map);
        setModel(retrofitApiSerivce.getMessageList(maps), subscriber);
    }

    /**
     * 删除消息列表
     */
    public void deleteMessageList(Map<String, Object> map, Subscriber subscriber) {
        Map<String, Object> maps = getMap(map);
        setModel(retrofitApiSerivce.deleteMessageList(maps), subscriber);
    }
    /**
     * 获取消息详情信息的接口
     */
    public void getMessageDetail(Map<String, Object> map, Subscriber subscriber) {
        Map<String, Object> maps = getMap(map);
        if (maps.get("id") != null) {
            try {
                id = (Integer) maps.get("id");
                maps.remove("id");
            } catch (Exception e) {
                e.printStackTrace();
                id = 0;
            }
        }
        setModel(retrofitApiSerivce.getMessageDetail(id, maps), subscriber);
    }

    /**
     * 获取公告列表
     */
    public void getNoticeList(Map<String, Object> map, Subscriber subscriber) {
        Map<String, Object> maps = getMap(map);
        setModel(retrofitApiSerivce.getNoticeList(maps), subscriber);
    }

    /**
     * 获取公告详情
     */
    public void getNoticeMessage(Map<String, Object> map, Subscriber subscriber) {
        Map<String, Object> maps = getMap(map);
        if (maps.get("id") != null) {
            try {
                id = (Integer) maps.get("id");
                maps.remove("id");
            } catch (Exception e) {
                e.printStackTrace();
                id = 0;
            }
        }
        setModel(retrofitApiSerivce.getNoticeMessage(id, maps), subscriber);
    }

    /**
     * 获取物资采购计划单列表
     */
    public void getCoursePlanList(Map<String, Object> map, Subscriber subscriber) {
        Map<String, Object> maps = getMap(map);
        setModel(retrofitApiSerivce.getCoursePlanList(maps), subscriber);
    }

    /**
     * 获取物资采购计划单详情
     */
    public void getCoursePlanMessage(Map<String, Object> map, Subscriber subscriber) {
        Map<String, Object> maps = getMap(map);
        if (maps.get("id") != null) {
            try {
                id = (Integer) maps.get("id");
                maps.remove("id");
            } catch (Exception e) {
                e.printStackTrace();
                id = 0;
            }
        }
        setModel(retrofitApiSerivce.getCoursePlanMessage(id, maps), subscriber);
    }

    /**
     * 获取物资采购计划单明细
     */
    public void getCoursePlanDetail(Map<String, Object> map, Subscriber subscriber) {
        Map<String, Object> maps = getMap(map);
        if (maps.get("id") != null) {
            try {
                id = (Integer) maps.get("id");
                maps.remove("id");
            } catch (Exception e) {
                e.printStackTrace();
                id = 0;
            }
        }
        setModel(retrofitApiSerivce.getCoursePlanDetail(id, maps), subscriber);
    }
    /**
     * 获取物资采购计划单服务明细
     */
    public void getCoursePlanServiceDetail(Map<String, Object> map, Subscriber subscriber) {
        Map<String, Object> maps = getMap(map);
        if (maps.get("id") != null) {
            try {
                id = (Integer) maps.get("id");
                maps.remove("id");
            } catch (Exception e) {
                e.printStackTrace();
                id = 0;
            }
        }
        setModel(retrofitApiSerivce.getCoursePlanServiceDetail(id, maps), subscriber);
    }

    /**
     * 获取物资采购需求单列表
     */
    public void getCourseGoodsDemandList(Map<String, Object> map, Subscriber subscriber) {
        Map<String, Object> maps = getMap(map);
        setModel(retrofitApiSerivce.getCourseGoodsDemandList(maps), subscriber);
    }

    /**
     * 获取物资采购需求单详情
     */
    public void getCourseGoodsDemandMessage(Map<String, Object> map, Subscriber subscriber) {
        Map<String, Object> maps = getMap(map);
        if (maps.get("id") != null) {
            try {
                id = (Integer) maps.get("id");
                maps.remove("id");
            } catch (Exception e) {
                e.printStackTrace();
                id = 0;
            }
        }
        setModel(retrofitApiSerivce.getCourseGoodsDemandMessage(id, maps), subscriber);
    }

    /**
     * 获取物资采购需求单明细
     */
    public void getCourseGoodsDemandDetail(Map<String, Object> map, Subscriber subscriber) {
        Map<String, Object> maps = getMap(map);
        if (maps.get("id") != null) {
            try {
                id = (Integer) maps.get("id");
                maps.remove("id");
            } catch (Exception e) {
                e.printStackTrace();
                id = 0;
            }
        }
        setModel(retrofitApiSerivce.getCourseGoodsDemandDetail(id, maps), subscriber);
    }

    /**
     * 获取物资采购订单列表
     */
    public void getCourseGoodsOrderList(Map<String, Object> map, Subscriber subscriber) {
        Map<String, Object> maps = getMap(map);
        setModel(retrofitApiSerivce.getCourseGoodsOrderList(maps), subscriber);
    }

    /**
     * 获取物资采购订单详情
     */
    public void getCourseGoodsOrderMessage(Map<String, Object> map, Subscriber subscriber) {
        Map<String, Object> maps = getMap(map);
        if (maps.get("id") != null) {
            try {
                id = (Integer) maps.get("id");
                maps.remove("id");
            } catch (Exception e) {
                e.printStackTrace();
                id = 0;
            }
        }
        setModel(retrofitApiSerivce.getCourseGoodsOrderMessage(id, maps), subscriber);
    }

    /**
     * 获取物资采购订单明细
     */
    public void getCourseGoodsOrderDetail(Map<String, Object> map, Subscriber subscriber) {
        Map<String, Object> maps = getMap(map);
        if (maps.get("id") != null) {
            try {
                id = (Integer) maps.get("id");
                maps.remove("id");
            } catch (Exception e) {
                e.printStackTrace();
                id = 0;
            }
        }
        setModel(retrofitApiSerivce.getCourseGoodsOrderDetail(id, maps), subscriber);
    }

    /**
     * 获取物资采购验收单列表
     */
    public void getCourseGoodsExamineList(Map<String, Object> map, Subscriber subscriber) {
        Map<String, Object> maps = getMap(map);
        setModel(retrofitApiSerivce.getCourseGoodsExamineList(maps), subscriber);
    }

    /**
     * 获取物资采购验收单详情
     */
    public void getCourseGoodsExamineMessage(Map<String, Object> map, Subscriber subscriber) {
        Map<String, Object> maps = getMap(map);
        if (maps.get("id") != null) {
            try {
                id = (Integer) maps.get("id");
                maps.remove("id");
            } catch (Exception e) {
                e.printStackTrace();
                id = 0;
            }
        }
        setModel(retrofitApiSerivce.getCourseGoodsExamineMessage(id, maps), subscriber);
    }

    /**
     * 获取物资采购验收单明细
     */
    public void getCourseGoodsExamineDetail(Map<String, Object> map, Subscriber subscriber) {
        Map<String, Object> maps = getMap(map);
        if (maps.get("id") != null) {
            try {
                id = (Integer) maps.get("id");
                maps.remove("id");
            } catch (Exception e) {
                e.printStackTrace();
                id = 0;
            }
        }
        setModel(retrofitApiSerivce.getCourseGoodsExamineDetail(id, maps), subscriber);
    }

    /**
     * 获取服务任务需求单列表
     */
    public void getCourseServiceDemandList(Map<String, Object> map, Subscriber subscriber) {
        Map<String, Object> maps = getMap(map);
        setModel(retrofitApiSerivce.getCourseServiceDemandList(maps), subscriber);
    }

    /**
     * 获取服务任务需求单详情
     */
    public void getCourseServiceDemandMessage(Map<String, Object> map, Subscriber subscriber) {
        Map<String, Object> maps = getMap(map);
        if (maps.get("id") != null) {
            try {
                id = (Integer) maps.get("id");
                maps.remove("id");
            } catch (Exception e) {
                e.printStackTrace();
                id = 0;
            }
        }
        setModel(retrofitApiSerivce.getCourseServiceDemandMessage(id, maps), subscriber);
    }

    /**
     * 获取服务任务需求单明细
     */
    public void getCourseServiceDemandDetail(Map<String, Object> map, Subscriber subscriber) {
        Map<String, Object> maps = getMap(map);
        if (maps.get("id") != null) {
            try {
                id = (Integer) maps.get("id");
                maps.remove("id");
            } catch (Exception e) {
                e.printStackTrace();
                id = 0;
            }
        }
        setModel(retrofitApiSerivce.getCourseServiceDemandDetail(id, maps), subscriber);
    }

    /**
     * 获取服务任务订单列表
     */
    public void getCourseServiceOrderList(Map<String, Object> map, Subscriber subscriber) {
        Map<String, Object> maps = getMap(map);
        setModel(retrofitApiSerivce.getCourseServiceOrderList(maps), subscriber);
    }

    /**
     * 获取服务任务订单详情
     */
    public void getCourseServiceOrderMessage(Map<String, Object> map, Subscriber subscriber) {
        Map<String, Object> maps = getMap(map);
        if (maps.get("id") != null) {
            try {
                id = (Integer) maps.get("id");
                maps.remove("id");
            } catch (Exception e) {
                e.printStackTrace();
                id = 0;
            }
        }
        setModel(retrofitApiSerivce.getCourseServiceOrderMessage(id, maps), subscriber);
    }

    /**
     * 获取服务任务订单明细
     */
    public void getCourseServiceOrderDetail(Map<String, Object> map, Subscriber subscriber) {
        Map<String, Object> maps = getMap(map);
        if (maps.get("id") != null) {
            try {
                id = (Integer) maps.get("id");
                maps.remove("id");
            } catch (Exception e) {
                e.printStackTrace();
                id = 0;
            }
        }
        setModel(retrofitApiSerivce.getCourseServiceOrderDetail(id, maps), subscriber);
    }

    /**
     * 获取服务任务验收单列表
     */
    public void getCourseServiceExamineList(Map<String, Object> map, Subscriber subscriber) {
        Map<String, Object> maps = getMap(map);
        setModel(retrofitApiSerivce.getCourseServiceExamineList(maps), subscriber);
    }

    /**
     * 获取服务任务验收单详情
     */
    public void getCourseServiceExamineMessage(Map<String, Object> map, Subscriber subscriber) {
        Map<String, Object> maps = getMap(map);
        if (maps.get("id") != null) {
            try {
                id = (Integer) maps.get("id");
                maps.remove("id");
            } catch (Exception e) {
                e.printStackTrace();
                id = 0;
            }
        }
        setModel(retrofitApiSerivce.getCourseServiceExamineMessage(id, maps), subscriber);
    }

    /**
     * 获取服务任务验收单明细
     */
    public void getCourseServiceExamineDetail(Map<String, Object> map, Subscriber subscriber) {
        Map<String, Object> maps = getMap(map);
        if (maps.get("id") != null) {
            try {
                id = (Integer) maps.get("id");
                maps.remove("id");
            } catch (Exception e) {
                e.printStackTrace();
                id = 0;
            }
        }
        setModel(retrofitApiSerivce.getCourseServiceExamineDetail(id, maps), subscriber);
    }

    /**
     * 获取付款申请单列表
     */
    public void getCourseFinanceList(Map<String, Object> map, Subscriber subscriber) {
        Map<String, Object> maps = getMap(map);
        setModel(retrofitApiSerivce.getCourseFinanceList(maps), subscriber);
    }

    /**
     * 获取付款申请单详情
     */
    public void getCourseFinanceMesage(Map<String, Object> map, Subscriber subscriber) {
        Map<String, Object> maps = getMap(map);
        if (maps.get("id") != null) {
            try {
                id = (Integer) maps.get("id");
                maps.remove("id");
            } catch (Exception e) {
                e.printStackTrace();
                id = 0;
            }
        }
        setModel(retrofitApiSerivce.getCourseFinanceMesage(id, maps), subscriber);
    }

    /**
     * 获取已办事项列表
     */
    public void getMatterFinishedList(Map<String, Object> map, Subscriber subscriber) {
        Map<String, Object> maps = getMap(map);
        setModel(retrofitApiSerivce.getMatterFinishedList(maps), subscriber);
    }
    /**
     * 获取进度追踪的列表
     */
    public void getHomeMatterList(Map<String, Object> map, Subscriber subscriber) {
        Map<String, Object> maps = getMap(map);
        setModel(retrofitApiSerivce.getHomeMatterList(maps), subscriber);
    }
    /**
     * 获取未办事项列表
     */
    public void getMatterUnFinishList(Map<String, Object> map, Subscriber subscriber) {
        Map<String, Object> maps = getMap(map);
        setModel(retrofitApiSerivce.getMatterUnFinishList(maps), subscriber);
    }

    /**
     * 获取供应商列表
     */
    public void getSupplierList(Map<String, Object> map, Subscriber subscriber) {
        Map<String, Object> maps = getMap(map);
        setModel(retrofitApiSerivce.getSupplierList(maps), subscriber);
    }

    /**
     * 获取供应商详情
     */
    public void getSupplierMesage(Map<String, Object> map, Subscriber subscriber) {
        Map<String, Object> maps = getMap(map);
        if (maps.get("id") != null) {
            try {
                id = (Integer) maps.get("id");
                maps.remove("id");
            } catch (Exception e) {
                e.printStackTrace();
                id = 0;
            }
        }
        setModel(retrofitApiSerivce.getSupplierMesage(id, maps), subscriber);
    }

    /**
     * 获取供应商物品列表
     */
    public void getSupplierProjectList(Map<String, Object> map, Subscriber subscriber) {
        Map<String, Object> maps = getMap(map);
        setModel(retrofitApiSerivce.getSupplierProjectList(maps), subscriber);
    }

    /**
     * 获取供应商物品详情
     */
    public void getSupplierProjectMesage(Map<String, Object> map, Subscriber subscriber) {
        Map<String, Object> maps = getMap(map);
        if (maps.get("id") != null) {
            try {
                id = (Integer) maps.get("id");
                maps.remove("id");
            } catch (Exception e) {
                e.printStackTrace();
                id = 0;
            }
        }
        setModel(retrofitApiSerivce.getSupplierProjectMesage(id, maps), subscriber);
    }

    /**
     * 获取供应商服务列表
     */
    public void getSupplierServiceList(Map<String, Object> map, Subscriber subscriber) {
        Map<String, Object> maps = getMap(map);
        setModel(retrofitApiSerivce.getSupplierServiceList(maps), subscriber);
    }

    /**
     * 获取供应商服务详情
     */
    public void getSupplierServiceMesage(Map<String, Object> map, Subscriber subscriber) {
        Map<String, Object> maps = getMap(map);
        if (maps.get("id") != null) {
            try {
                id = (Integer) maps.get("id");
                maps.remove("id");
            } catch (Exception e) {
                e.printStackTrace();
                id = 0;
            }
        }
        setModel(retrofitApiSerivce.getSupplierServiceMesage(id, maps), subscriber);
    }

    /**
     * 对单据进行批准的操作
     */
    public void setOrderApproval(Map<String, Object> map, Subscriber subscriber) {
        Map<String, Object> maps = getMap(map);
        if (maps.get("id") != null) {
            try {
                id = (Integer) maps.get("id");
                maps.remove("id");
            } catch (Exception e) {
                e.printStackTrace();
                id = 0;
            }
        }
        setModel(retrofitApiSerivce.setOrderApproval(id, maps), subscriber);
    }

    /**
     * 对单据进行撤销的操作
     */
    public void setOrderCancel(Map<String, Object> map, Subscriber subscriber) {
        Map<String, Object> maps = getMap(map);
        if (maps.get("id") != null) {
            try {
                id = (Integer) maps.get("id");
                maps.remove("id");
            } catch (Exception e) {
                e.printStackTrace();
                id = 0;
            }
        }
        setModel(retrofitApiSerivce.setOrderCancel(id, maps), subscriber);
    }

    /**
     * 对单据进行退回的操作
     */
    public void setOrderReject(Map<String, Object> map, Subscriber subscriber) {
        Map<String, Object> maps = getMap(map);
        if (maps.get("id") != null) {
            try {
                id = (Integer) maps.get("id");
                maps.remove("id");
            } catch (Exception e) {
                e.printStackTrace();
                id = 0;
            }
        }
        setModel(retrofitApiSerivce.setOrderReject(id, maps), subscriber);
    }

    /**
     * 获取首页banner图列表
     */
    public void getBannerList(Map<String, Object> map, Subscriber subscriber) {
        Map<String, Object> maps = getMap(map);
        setModel(retrofitApiSerivce.getBannerList(maps), subscriber);
    }

    /**
     * 获取部门统计数据的接口
     */
    public void getStatisticsDeptList(Map<String, Object> map, Subscriber subscriber) {
        Map<String, Object> maps = getMap(map);
        String type = "";
        if (maps.get("type") != null) {
            try {
                type = (String) maps.get("type");
                maps.remove("type");
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        setModel(retrofitApiSerivce.getStatisticsDeptList(type, maps), subscriber);
    }

    /**
     * 获取供应商统计数据的接口
     */
    public void getStatisticsSupplierList(Map<String, Object> map, Subscriber subscriber) {
        Map<String, Object> maps = getMap(map);
        String type = "";
        if (maps.get("type") != null) {
            try {
                type = (String) maps.get("type");
                maps.remove("type");
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        setModel(retrofitApiSerivce.getStatisticsSupplierList(type, maps), subscriber);
    }

    /**
     * 获取统计模块刷选条件的部门列表
     */
    public void getStatisticsConditionDeptList(Map<String, Object> map, Subscriber subscriber) {
        Map<String, Object> maps = getMap(map);
        int companyId = 0;
        if (maps.get("companyId") != null) {
            try {
                companyId = (int) maps.get("companyId");
                maps.remove("companyId");
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        setModel(retrofitApiSerivce.getStatisticsConditionDeptList(companyId, maps), subscriber);
    }

    /**
     * 获取统计模块刷选条件的供应商列表
     */
    public void getStatisticsConditionSupplierList(Map<String, Object> map, Subscriber subscriber) {
        Map<String, Object> maps = getMap(map);
        setModel(retrofitApiSerivce.getStatisticsConditionSupplierList(maps), subscriber);
    }

}
